{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
<form class="layui-form body-content">
  <h3 style="height:36px">重置密码</h3>
  <table class="layui-table layui-table-form">
    <tr>
      <td class="layui-td-gray2">用户名 <span style="color: red">*</span></td>
      <td><input type="text" lay-verify="required" autocomplete="off" placeholder="" class="layui-input"
        value="{$admin.username}" disabled></td>
      <td class="layui-td-gray2">旧密码<span style="color: red">*</span></td>
      <td>
        <input type="password" lay-verify="required" name="old_pwd" placeholder="请输入旧密码" lay-reqText="请输入旧密码" autocomplete="off" class="layui-input">
      </td>
    </tr>
    <tr>
      <td class="layui-td-gray2">新密码 <span style="color: red">*</span></td>
      <td>
        <input type="password" lay-verify="required" name="pwd" placeholder="请输入新密码" lay-reqText="请输入新密码"  autocomplete="off" class="layui-input">
      </td>
      <td class="layui-td-gray2">确认新密码 <span style="color: red">*</span></td>
      <td>
        <input type="password" lay-verify="required" name="pwd_confirm" placeholder="请再次输入新密码"  lay-reqText="请再次输入新密码" autocomplete="off" class="layui-input">
      </td>
    </tr>
  </table>
	<div style="padding: 10px 0">
		<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
		<button type="reset" class="layui-btn layui-btn-primary">重置</button>
	</div>
</form>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
  function init(layui) {
	var TAB = parent.layui.tab,
		form = layui.form,
		layer = layui.layer;
    //监听提交
    form.on('submit(webform)', function (data) {
      $.ajax({
        url: "/admin/api/password_submit",
        type: 'post',
        data: data.field,
        success: function (e) {
          if (e.code == 0) {
            layer.msg('修改密码成功');
            setTimeout(function () {
				TAB.sonDelete();
				layer.close(index);
            }, 1000)
          } else {
            layer.msg(e.msg);
          }
        }
      })
      return false;
    });
  }

</script>
{include file="common/layui" base='base' extend="[]" callback="init" /}
{/block}
<!-- /脚本 -->